package com.modifiertech.lineage.utils;

import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;

/**
 * @description: default
 * @author: saliencemn
 * @mail: hackingmu@outlook.com
 * @date: 2024/9/4 23:24
 */
public class AABBUtil {

    /**根据中心点与最终范围获取AABB盒
     *
     * @param centerPos 中心点
     * @param range 选框范围(直径,尽量保持奇数)
     * @param height 选框高度
     * @return
     */
    public static AxisAlignedBB getAABBFromCenterPos(BlockPos centerPos,int range,int height){
//        -1 0 1
        int shifting = (int) Math.round(range/2-0.5);
        BlockPos minBlockPos = centerPos.add(0-shifting,0,0-shifting)
                .add(-0.5,0,-0.5);
        BlockPos maxBlockPos = centerPos.add(0+shifting,0,0+shifting)
                .add(1.5,height,1.5);
        AxisAlignedBB axisAlignedBB = new AxisAlignedBB(minBlockPos,maxBlockPos);
        return axisAlignedBB;
    }


}
